from sqlalchemy import Column, String, UniqueConstraint, Text

from server.framework.core.models import CoreModel


class IdeStack(CoreModel):
    """
    技术栈
    """
    __tablename__ = "ide_stack"

    name = Column(String(length=256), comment="技术栈名称", nullable=False)
    image = Column(String(length=256), comment="镜像名称", nullable=False)
    command = Column(Text, comment="启动命令")
    args = Column(Text, comment="启动参数")
    volume_config = Column(Text, default='', comment="卷的挂载配置,如[/mnt:/mnt;/etc:/etc]")
    port_config = Column(Text, default='', comment="端口的配置,如[name1:9000;name2:9001]")
    ingress_config = Column(Text, default='', comment="反向代理的配置,如[name1:9000;name2:9001]")
    env_config = Column(Text, default='', comment="环境变量的配置,如[name1:9000;name2:9001]")
    tenant_id = Column(String(length=256), comment="租户ID")
    __table_args__ = (UniqueConstraint('name', 'tenant_id', name='uk_ide_stack'),)
